'use strict'
import MMALL_COMM from 'util/comm.jsx';
const _comm = new MMALL_COMM();
class Product {
    //获取商品列表
    getProductList(listParam){
        if(listParam.listType == 'list'){
            return _comm.request({
                url     : _comm.getServerHost('/manage/product/list.do'),
                data    : {
                    pageNum : listParam.pageNum || 1
                }
            });
        }
        else if(listParam.listType == 'search'){
            return _comm.request({
                url     : _comm.getServerHost('/manage/product/search.do'),
                data    : listParam
            });
        }
            
    }
    //改变上下架状态
    setSaleStatus(productInfo){
        return _comm.request({
            url     : _comm.getServerHost('/manage/product/set_sale_status.do'),
            data    : productInfo,
            method  : "post"
        });   
    }
    //获得分类列表
    getCategory(parentCategoryId){
        return _comm.request({
            url     : _comm.getServerHost('/manage/category/get_category.do'),
            data    : {
                categoryId : parentCategoryId || 0
            }
        });
    }
    // 新增商品
    saveProduct(product){
        return _comm.request({
            url     : _comm.getServerHost('/manage/product/save.do'),
            data    : product
        });
    }
    // 获取商品信息
    getProduct(productId){
        return _comm.request({
            url     : _comm.getServerHost('/manage/product/detail.do'),
            data    : {
                productId : productId || 0
            }
        });
    }
}
export default Product